import { defineStore } from 'pinia'
import { getAllGroupById,getGroupDetail,deleteGroup } from '@/api/groupHttp'

// 所有药品
export const useGroupStore = defineStore('group', {
  state: () => ({
    category:[],
    categoryDetail:[]
  }),
  
  getters: {
    
  },
  
  actions: {
    async getAllGroupById(){
      const {data:{data} } = await getAllGroupById()
      this.category = data.filter(item => item.categoryStatus === 0);
      console.log(data);
    },
    async getDetail(id){
      const {data:{data}} = await getGroupDetail(id)
      this.categoryDetail = data 
      console.log(data);
    },
    async deleteGroup(id){
      await deleteGroup(id,1)
      this.category = this.category.filter(medicine => medicine.id!== id);
    }
  }
}) 

